package com.xixing.weixin.domain;

import javax.persistence.Column;
import javax.validation.constraints.NotNull;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;
import org.springframework.roo.addon.tostring.RooToString;

import java.util.List;

@SuppressWarnings("JpaQlInspection")
@RooJavaBean
@RooToString
@RooJpaActiveRecord(finders = "findSchoolsByWeixinCode")
public class School {

    @NotNull
    private String schoolName;

    @NotNull
    private String weixinToken;

    @Column(unique = true)
    private String weixinCode;

    private String schoolAddress;

    private String schoolLongitude;

    private String schoolLatitude;

    public static List<String> findAllSchoolTokens() {
        return entityManager().createQuery("SELECT o.weixinToken FROM School o", String.class).getResultList();
    }
}
